<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('留言列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="col-sm-12 search-collapse ifcomebody1">
        <form id="formId">
            <div class="select-list">
                <ul>
                    <li>
                        <label>姓名 </label>
                        <input type="text" name="name" placeholder="请输入姓名"/>
                    </li>
                    <li>
                        <label>联系方式 </label>
                        <input type="text" name="tel" placeholder="请输入联系方式"/>
                    </li>
                        <!-- 临床招募类型 留言-->
                        <input type="hidden" name="type" value="01"/>
                    <li>
                        <a class="btn btn-chongzhi btn-rounded mr16 btn-sm" onclick="$.form.reset()">重置</a>
                        <a class="btn btn-chaxun  mr16 btn-rounded btn-sm" onclick="$.table.search()">查询</a>
                    </li>
                </ul>
            </div>
        </form>
    </div>

    <div class="btn-group-sm" style="display: flex;" id="toolbar" role="group">

        <a class="btn btn-newadd multiple disabled" onclick="$.operate.removeAll()"
           shiro:hasPermission="ydz:leaveWord:remove">
            <i class="fa fa-remove"></i> 删除
        </a>
        <a class="btn btn-newadd" onclick="$.table.exportExcel()" shiro:hasPermission="ydz:leaveWord:export">
            <i class="fa fa-download"></i> 导出
        </a>
    </div>
    <div class="col-sm-12 select-table table-striped ifcomebody">
        <table id="bootstrap-table"></table>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('ydz:leaveWord:edit')}]];
    var removeFlag = [[${@permission.hasPermi('ydz:leaveWord:remove')}]];
    var statusDatas = [[${@dict.getType('handle_state')}]];
    var prefix = ctx + "ydz/leaveWord";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "留言",
            columns: [{
                checkbox: true
            },
                        {
                            field: 'id',
                            title: '主键',
                            visible: false
                        },
                        {
                            field: 'name',
                            title: '姓名'
                        },
                        {
                            field: 'tel',
                            title: '留电'
                        },
                        {
                            field: 'content',
                            title: '疾病名称'
                        },
                        {
                            field: 'remark',
                            title: '备注'
                        },
                        {
                            field: 'createTime',
                            title: '创建时间'
                        },
                        {
                            field: 'status',
                            title: '处理状态',
                            width:100,
                            formatter: function (value, row, index) {
                                let className = "";
                                if (value == 1) {
                                    className = "badge warning"
                                } else if (value == 2) {
                                    className = "badge end"
                                }
                                let a = '<div class="' + className + '">' + $.table.selectDictLabel(statusDatas, value) + '</div>'
                                return a;
                            }
                        },
                        {
                            field: 'updateBy',
                            title: '更新人'
                        },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-caozuo btn-xs " href="javascript:void(0)" onclick="updateStatus(\'' + row.status + "," + row.id + '\')">变更</a> ');
                        actions.push('<a class="btn btn-caozuo btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')">删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    //变更申请状态
    function updateStatus(state, id) {
        let arr = state.split(',')
        let State = arr[0]
        let Id = arr[1]
        debugger
        if (State == 1) {
            $.modal.popUpConfirm("您确认要变更该申请为已处理吗？", function () {
                $.operate.post(prefix + "/edit", {"id": Id, "status": 2});
            })
        } else if (State == 2) {
            $.modal.alertError("无法变更已处理的申请", function () {
                // $.operate.post(prefix + "/edit", {"id": Id, "state": 1});
            })
        }
    }
</script>
</body>
</html>